﻿@using Entidades.Sistema.Venta
@using Entidades.Sistema.Base
@using System.Collections.ObjectModel;
@using System.Collections.Generic;

@model Entidades.Sistema.Base.Zona
@*<link href="../../Content/themes/bootstrap.extra.table.css" rel="stylesheet" />*@
@{
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
    List<Empleado> _EmpleadoList = (List<Empleado>)ViewBag.Empleado;
}

@using (Html.BeginForm("EditZonaUpdatePartial", "Zona", FormMethod.Post, new { @class = "edit_form", style = "height: 210px;" }))
{
    
    <div class="span6"> 
     <div class="BottomPadding">Zona</div>
     <br />
    @Html.Hidden("IdZona")
    <div class="line">
        @Html.DevExpress().Label(
            settings =>
            {
                settings.ControlStyle.CssClass = "label";
                settings.Text = "Nombre Zona:";
                settings.AssociatedControlName = "Nombre";
            }
        ).GetHtml()
        @Html.DevExpress().TextBox(
            settings =>
            {
                settings.Name = "Nombre";
                settings.ControlStyle.CssClass = "editor";
                settings.ShowModelErrors = true;
                settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
            }
        ).Bind(Model.Nombre).GetHtml()
        
    </div>

    <div class="line">
        @Html.DevExpress().Label(
            settings =>
            {
                settings.ControlStyle.CssClass = "label";
                settings.AssociatedControlName = "Empleado.NombreApellido";
                settings.Text = "Empleado:";
            }
        ).GetHtml()
        @Html.DevExpress().ComboBox(
            settings =>
            {
                settings.Name = "IdEmpleado";
                settings.ControlStyle.CssClass = "editor";
                settings.Properties.TextField = "NombreApellido";
                settings.Properties.ValueField = "IdEmpleado";
                settings.Properties.ValueType = typeof(int);


                settings.Properties.ClientSideEvents.Init = "function(s,e){if(s.GetValue()=='0'){ s.SetValue(null);} }";
                settings.ShowModelErrors = true;
                settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
            }
        ).BindList(_EmpleadoList).Bind(Model.Empleado.IdEmpleado).GetHtml()
    </div>
    
    
    <div class="line">
        @Html.DevExpress().Label(
            settings =>
            {
                settings.ControlStyle.CssClass = "label";
            }
        ).GetHtml()
        @Html.DevExpress().Button(
            settings =>
            {
                settings.Name = "btnUpdate";
                settings.ControlStyle.CssClass = "button";
                settings.Text = "Actualizar";
                settings.UseSubmitBehavior = true;
            }
        ).GetHtml()
        @Html.DevExpress().Button(
            settings =>
            {
                settings.Name = "btnCancel";
                settings.ControlStyle.CssClass = "button";
                settings.Text = "Cancelar";
                settings.ClientSideEvents.Click = "function(s, e){ document.location='" + DevExpressHelper.GetUrl(new { Controller = "Zona", Action = "Index" }) + "'; }";
            }
        ).GetHtml()
    </div>
    
  </div>
     
    <div class="BottomPadding">Barrios:</div>
    <br />
    @Html.DevExpress().ListBox(
    settings =>
    {
        settings.Name = "lbModels";
        settings.CallbackRouteValues = new { Controller = "Editors", Action = "ListBoxPartial" };
        settings.Width = 300;
        settings.Height = 210;
        settings.Properties.EnableClientSideAPI = true;
        settings.Properties.SelectionMode = ListEditSelectionMode.CheckColumn;
        settings.Properties.ValueField = "IdBarrio";
        settings.Properties.TextField = "Nombre";
        settings.Properties.ValueType = typeof(string);
        settings.PreRender = (sender, e) =>
        {
            ASPxListBox cbl = (ASPxListBox)sender;
            foreach (ListEditItem item in cbl.Items)
            {
                if (Model.Barrios.Any(x => x.IdBarrio == Convert.ToInt32(item.Value)))
                    item.Selected = true;
            }
        };
    }).BindList(ViewBag.Barrio).GetHtml()
    
}















